package com.datauuu;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 * 程序入口.
 *
 * @author sunym1993
 * @version 0.0.1-SNAPSHOT
 * @since 2018年01月05日 13时21分
 */
public class Run {

    public static void main(String[] args) throws Exception {
        List<Money> moneys = getMoneyList();
        List<Loan> loans = getLoanList();

        List<Rel> results = OOMMatch(moneys, loans);
    }

    public static List<Rel> OOMMatch(List<Money> moneys, List<Loan> loans) {

        return null;
    }

    /**
     * 读取文件，输出里面的内容，通用方法
     */
    public static List<Money> getMoneyList() throws Exception {
        List<Money> list = new ArrayList<>();
        InputStream is = Run.class.getClassLoader().getResourceAsStream("money.csv");
        InputStreamReader reader = new InputStreamReader(is, "utf-8");
        BufferedReader br = new BufferedReader(reader);
        String s = "";
        while ((s = br.readLine()) != null) {
            String[] sp = s.split(",");
            list.add(new Money(sp[0], Long.parseLong(sp[1]), Integer.parseInt(sp[2]), Integer.parseInt(sp[3])));
        }
        is.close();
        return list;
    }

    /**
     * 读取文件，输出里面的内容，通用方法
     */
    public static List<Loan> getLoanList() throws Exception {
        List<Loan> list = new ArrayList<>();
        InputStream is = Run.class.getClassLoader().getResourceAsStream("loan.csv");
        InputStreamReader reader = new InputStreamReader(is, "utf-8");
        BufferedReader br = new BufferedReader(reader);
        String s = "";
        while ((s = br.readLine()) != null) {
            String[] sp = s.split(",");
            list.add(new Loan(sp[0], Long.parseLong(sp[1]), Integer.parseInt(sp[2])));
        }
        is.close();
        return list;
    }

}
